# coding=utf-8
# author : soliton
# gmail  : soliton.wang@gmail.com
# qq     : 1670829014

import re
import urllib
import requests
from lxml import etree
from bs4 import BeautifulSoup
from ping3 import ping, verbose_ping

class YunWei_Tools:
    def __init__(self):
        """
        生成URL二维码图片接口地址
        """
        self.QRcode_URL = "https://api.oick.cn/qrcode/api.php"

        """
        网易云音乐下载接口地址
        """
        self.Wyy_URL = "https://api.oick.cn/wyy/api.php"

        """
        ICP 备案查询
        """
        self.ICP_URL = "https://api.oick.cn/icp/api.php"

        """
        API_URL
        """
        self.API_URL = "https://v1.alapi.cn/api/url"



    def Qrcode(self, url):
        size = 200
        params = {
            "text": url,
            "size": size
        }
        Qrcode_name = url[:-1].strip("https://").strip("http://") + ".png"
        response = requests.get(self.QRcode_URL, params=params).content
        f = open("Qrcode\\" + Qrcode_name, "wb+")
        f.write(response)
        f.close()

    def WY_Music(self, id, name):
        params = {
            "id": str(id)
        }
        response = requests.get(self.Wyy_URL, params=params).content
        f = open("Music-163.com\\" + str(name) + ".mp3", "wb+")
        f.write(response)
        f.close()


    def ICP(self, Domain):
        params = {
            "url": str(Domain)
        }
        response = requests.get(self.ICP_URL, params=params).text
        print(response)

    def URL_API(self, url=""):
        params = {
            "url": url
        }
        response = requests.get(url=self.API_URL, params=params).json()
        print(response)

    def PING(self, ):
        """
             Ping :
                 测试域名是否解析或是IP是否能够进行通信
         """

        info = ping("192.168.0.110")
        print(info)
        verbose_ping("192.168.0.110")
if __name__ == '__main__':
    App = YunWei_Tools()
    # App.Qrcode("http://blog.soliton.wang/")
    # App.WY_Music("865040149", "这是朕的江山--诗者言辞")
    # App.ICP("soliton.wang")
    # App.URL_API("http://blog.soliton.wang/archives/zabbix542-zabbix-server")
    App.PING()


